package ou;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class GuanYu {

    private String name="关二爷";
    //解耦的依赖,声明的类型是接口或抽象类,不声明具体可实例化的类型
    @Autowired
    //@Qualifier注解表示自动装配的对象指定Spring容器中对象的id
    @Qualifier("snakeLance")
    private Weapon weapon;

    public void fight(){
        System.out.println(name+"使用"+weapon+"战斗");
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Weapon getWeapon() {
        return weapon;
    }

    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
}
